
#ifndef _CHIP_MCP3421_H_
#define _CHIP_MCP3421_H_ 1

#ifdef  __cplusplus
    extern "C" {
#endif
// ---------- //

enum {
	MCP_AUTO_MODE = 1<<4,
	MCP_RATE_240SPS_12BIT = 00,
	MCP_RATE_60SPS_14BIT = 0x01<<2,
	MCP_RATE_15SPS_16BIT = 0x02<<2,
	MCP_RATE_3_75SPS_18BIT = 0x03<<2,
	MCP_GAIN_x1 = 0,
	MCP_GAIN_x2 = 1,
	MCP_GAIN_x4 = 2,
	MCP_GAIN_x8 = 3,
};
typedef struct
{
	uint8_t continuous;
	uint8_t sampleRate;
	uint8_t pgaGain;
	double voltage;
} MCP3421;

extern MCP3421 mcp3421;
void MCP3421_Configure(uint8_t autoConversion, uint8_t sampleRate, uint8_t gain);
double MCP3421_GetVoltage(void);


// ---------- //
#ifdef __cplusplus
}
#endif

#endif
